#include "stdio.h"
#include "string.h"
#include <stdlib.h>

#define SIZE_1 (10)
#define SIZE_2 (15)
void handle_error(void *p) {
  if (p == NULL) {
    fprintf(stderr, "alloc error\n");
    exit(1);
  }
}
int main() {
  int *p = NULL;
  int i = 0;
  p = malloc(SIZE_1 * sizeof(int));
  handle_error(p);
  for (; i < SIZE_1; i++) {
    p[i] = i;
  }
  p = realloc(p, SIZE_2);
  handle_error(p);
  for (i = 0; i < SIZE_2; i++) {
    printf("data[%d]:%d\n", i, p[i]);
  }
  free(p);
  return 0;
}
